var _extends = Object.assign || function(a) {
    for (var e = 1; e < arguments.length; e++) {
        var t, o = arguments[e];
        for (t in o) Object.prototype.hasOwnProperty.call(o, t) && (a[t] = o[t]);
    }
    return a;
}, _tools = require("../../utils/tools"), _page_urls = require("../../utils/page_urls"), _page_urls2 = _interopRequireDefault(_page_urls);

function _interopRequireDefault(a) {
    return a && a.__esModule ? a : {
        default: a
    };
}

var g, page_id, app = getApp(), page = app.page, request = app.util.request, route = app.route;

function getPgae() {
    request({
        url: "DiyInfo",
        data: {
            id: 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : page_id
        },
        success: function(a) {
            g.setData(_extends({}, a));
            a = a.page_data.head.params;
            wx.setNavigationBarColor({
                frontColor: a.titleTextColor ? "#ffffff" : "#ffffff",
                backgroundColor: a.backgroundColor,
                animation: {
                    duration: 400,
                    timingFunc: "easeIn"
                }
            }), wx.stopPullDownRefresh();
        }
    });
}

page({
    data: {
        isShow: !1,
        las: !1,
        barStyle: '',
        navBarHeightNew: 0,
        statusBarHeight: 0
    },
    audioAction: {
        method: "pause"
    },
    onLoad: function(a) {
        g = this, page_id = a.id;
        a = wx.getStorageSync("showAddxcx");
        g.setData({
            showAddxcx: "boolean" != typeof a || a
        }), getPgae();
        let sys = wx.getSystemInfoSync()
        let menu = wx.getMenuButtonBoundingClientRect()
        let navBarHeightNew = 44
        g.setData({
          barStyle: "position:fixed;top:0;z-index:1;left:0;width:100%;padding-right:"+menu.width+"px;background:#294586;color:#fff;display:flex;justify-content: center;flex-direction: column;height:"+(navBarHeightNew + sys.statusBarHeight) + "px;padding-top:"+ sys.statusBarHeight + "px",
          navBarHeightNew,
          statusBarHeight: sys.statusBarHeight
        })
        let userInfo = wx.getStorageSync("userInfo")
        if(userInfo){
          request({
            url: "AddUsersLog",
            data: {
              user_id: userInfo.id,
              url: '/u_pages/diy/index',
              title: "首页"
            },
            success: function(a) {
            }
          })
        }
    },
    onPullDownRefresh: function() {
        getPgae();
    },
    toPage: function(a) {
        a = a.currentTarget.dataset.item;
        route({
            url: a.linkUrl
        });
    },
    showNotice: function(a) {
        a = a.currentTarget.dataset, console.log(a), a.data && (g.setData({
            notice: {
                data: a.data,
                params: a.params
            }
        }), g.setData({
            isShow: !g.data.isShow
        }));
    },
    onShareAppMessage: function(a) {
        var e = g.data.page_data.head.params;
        return {
            title: e.title || g.data.system.xcx_name,
            imageUrl: e.page_img ? e.page_img_url : "",
            path: _page_urls2.default.loading + "?pid=" + app.userInfo.id
        };
    },
    onShareTimeline: function() {
        var a = g.data.page_data.head.params;
        return {
            title: g.data.system.xcx_name,
            query: "id=" + g.options.id + "&pid=" + app.userInfo.id,
            imageUrl: a.page_img ? a.page_img_url : ""
        };
    },
    close: function() {
        wx.setStorageSync("showAddxcx", !1), g.setData({
            showAddxcx: !1
        });
    },
    toNew: function(t) {
      route({
          url: "news_info",
          params: {
              index: t.currentTarget.dataset.d[1],
              id: t.currentTarget.dataset.d[0]
          }
      });
    },
    toLawyer: function(t) {
      t = t.currentTarget.dataset.id;
      app.route({
          type: "navigate",
          url: "lawyer_info",
          params: {
              id: t
          }
      });
    },
    toWenda: function(t) {
      route({
          url: "wenda_info",
          params: {
              id: t.currentTarget.dataset.item.id
          }
      });
  }
});